import 'dio_util.dart';

class GateWayDio {
  static Future<Map<String, dynamic>> GetStatistical() async {
    Map<String, dynamic> result =
        await HoxinUtil.httpGet("/manage/GetStatistical", null);
    return result;
  }

  static Future<Map<String, dynamic>> GetCluserList() async {
    Map<String, dynamic> result =
        await HoxinUtil.httpGet("/manage/GetCluserList", null);
    return result;
  }

  static Future<Map<String, dynamic>> GetClusterInfo(String servername) async {
    Map<String, dynamic> result = await HoxinUtil.httpGet(
        "/manage/GetClusterInfo?servername=$servername", null);
    return result;
  }

  static Future<Map<String, dynamic>> GetConnInfo() async {
    Map<String, dynamic> result =
        await HoxinUtil.httpGet("/manage/GetConnInfo", null);
    return result;
  }

  static Future<List<String>> GetChannels() async {
    Map<String, dynamic> result =
        await HoxinUtil.httpGet("/manage/GetChannels", null);
    return (result["channel_list"] as List<dynamic>)
        .map((e) => e as String)
        .toList();
  }

  static Future<int> GetChannelsCount(String servername) async {
    Map<String, dynamic> result = await HoxinUtil.httpGet(
        "/manage/GetChannelsCount?servername=$servername", null);
    if (result["total"] == null) {
      return 0;
    }
    return result["total"] as int;
  }
}
